package top.lfyao.designpattern.details.memento;
/**
 * 发起人
 */
public class Originator {
    private String state;

    // 创建一个备份，并将状态state保存在备份类的state中
    public Memento createMemento() {
        return new Memento(this.state);
    }
    //将备份的数据恢复
    public void recoverMemento(Memento memento) {
        this.state = memento.getState();
    }

    public void show() {
        System.out.println("state=" + this.state);
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }
}
